# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=just
pkgver=1.36.0
pkgrel=0
pkgdesc="Just a command runner"
url="https://github.com/casey/just"
arch="all"
license="CC0-1.0"
checkdepends="
	bash
	fzf
	python3
	"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/casey/just/archive/$pkgver/just-$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen

	mkdir -p completions
	local shell; for shell in bash fish zsh; do
		./target/release/just --completions $shell > completions/just.$shell
	done

	mkdir -p man
	./target/release/just --man > man/just.1
}

check() {
	# Skipped tests are somehow broken.
	cargo test --frozen -- \
		--skip choose::default \
		--skip edit::editor_precedence \
		--skip functions::env_var_functions \
		--skip completions::bash
}

package() {
	install -D -m755 target/release/just -t "$pkgdir"/usr/bin/

	install -D -m644 man/just.1 -t "$pkgdir"/usr/share/man/man1/

	install -D -m644 completions/just.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -D -m644 completions/just.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -D -m644 completions/just.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
750558dd52e3dc843c782d9284993ab7f4c5c82030e52a3fcba06457e40013383ae219dd21dacc679f7b3b5b143fca82824036a090d4a8c230cb14aea5050f0c  just-1.36.0.tar.gz
"
